package graph;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import javax.swing.JList;
import javax.swing.AbstractListModel;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.MatteBorder;
/**
 * 
 * @author Axel
 *
 */
@SuppressWarnings("serial")
public class SettingsWindow extends JFrame {

	private JPanel masterPane;
	private JTextField columnField;
	private JTextField rowField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SettingsWindow frame = new SettingsWindow();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SettingsWindow() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		masterPane = new JPanel();
		masterPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(masterPane);
		masterPane.setLayout(new BorderLayout(0, 0));
		
		JPanel settingsPane = new JPanel();
		masterPane.add(settingsPane, BorderLayout.CENTER);
		settingsPane.setLayout(new BorderLayout(0, 0));
		
		JPanel buttonsPane = new JPanel();
		buttonsPane.setBorder(new MatteBorder(0, 0, 0, 1, (Color) new Color(0, 0, 0)));
		settingsPane.add(buttonsPane, BorderLayout.EAST);
		buttonsPane.setLayout(new GridLayout(10, 1, 0, 0));
		
		JButton addButton = new JButton("Add");
		buttonsPane.add(addButton);
		
		JButton delButton = new JButton("Delete");
		buttonsPane.add(delButton);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBorder(new MatteBorder(0, 1, 0, 0, (Color) new Color(0, 0, 0)));
		settingsPane.add(scrollPane, BorderLayout.CENTER);
		
		JList<Object> sheetsList = new JList<Object>();
		scrollPane.setViewportView(sheetsList);
		sheetsList.setModel(new AbstractListModel<Object>() {
			String[] values = new String[] {"Test", "Test", "Test", "Test", "Test", "Test", "Test", "Test", "Test", "Test", "Test", "Test"};
			public int getSize() {
				return values.length;
			}
			public Object getElementAt(int index) {
				return values[index];
			}
		});
		
		JLabel titleLabel = new JLabel("Sheets settings");
		titleLabel.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
		titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
		settingsPane.add(titleLabel, BorderLayout.NORTH);
		
		JPanel sheetsSizePane = new JPanel();
		sheetsSizePane.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(0, 0, 0)));
		settingsPane.add(sheetsSizePane, BorderLayout.SOUTH);
		sheetsSizePane.setLayout(new GridLayout(1, 5, 0, 0));
		
		JLabel columnsLabel = new JLabel("Columns");
		columnsLabel.setHorizontalAlignment(SwingConstants.CENTER);
		sheetsSizePane.add(columnsLabel);
		
		columnField = new JTextField();
		sheetsSizePane.add(columnField);
		columnField.setColumns(10);
		
		JLabel rowsLabel = new JLabel("Rows");
		rowsLabel.setHorizontalAlignment(SwingConstants.CENTER);
		sheetsSizePane.add(rowsLabel);
		
		rowField = new JTextField();
		sheetsSizePane.add(rowField);
		rowField.setColumns(10);
		
		JButton saveButton = new JButton("Save");
		sheetsSizePane.add(saveButton);
		
		JPanel westPane = new JPanel();
		masterPane.add(westPane, BorderLayout.WEST);
		
		JPanel southPane = new JPanel();
		masterPane.add(southPane, BorderLayout.SOUTH);
		
		JPanel northPane = new JPanel();
		masterPane.add(northPane, BorderLayout.NORTH);
		
		JPanel eastPane = new JPanel();
		masterPane.add(eastPane, BorderLayout.EAST);
	}

}
